<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
<div style="padding-left:70px;padding-bottom:5px;padding-top: 25px;">
	<input id="file_upload" name="file_upload" type="file" />
</div>
<div style="text-align:center;margin-top: 40px">               
    <a class="mini-button" onclick="onOk" style="width:60px;">确定</a>       
    <a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>       
</div>

<script type="text/javascript">
mini.parse();
var storageId = "";

$(document).ready(function(){
	setTimeout(function(){
		$('#file_upload').uploadify({
			'auto':false,
			'swf':'scripts/uploadify/uploadify.swf',
			'uploader':'import_storage_medicine.do;jsessionid=<%=session.getId()%>',
			'fileSizeLimit':'5MB',
			'fileTypeExts':'*.xls',
			'fileTypeDesc':'xls',
			'buttonText':'选择文件',
			'queueSizeLimit':1,
			'method':'POST',
			'scriptData': {'storageId':storageId},
			'onUploadStart' : function(file) {
				if(storageId){
					$("#file_upload").uploadify("settings", "formData",{'storageId':storageId});
				}
				else{
					$('#file_upload').uploadify('cancel');
					alert("上传时发生错误，请刷新页面后重试！");
				}
				
			},
			'onUploadSuccess':function(file, data, response){
				data = eval('(' + data + ')');
				if(data.success){
	    			window.CloseOwnerWindow("succ");
				}else{
					mini.alert(data.message);
				}
			}
		});
	},5);
});

function CloseWindow(action) {            
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();            
}

function onOk(e) {
	$("#file_upload").uploadify('upload', '*');
}

function onCancel(e) {
	CloseWindow("cancel");
}

//标准方法接口定义
function SetData(data) {
     //跨页面传递的数据对象，克隆后才可以安全使用
     data = mini.clone(data);
     storageId = data.storageId;
}
</script>
</body>
</html>